package com.xinyuan.digit.next.subscriber.db.pojo;

import com.xinyuan.digit.next.subscriber.db.util.LambdaUtils;

import java.io.Serializable;

/**
 * 排序
 *
 * @author LiuChenghui 2025/10/23 15:24:00
 * @version 1.0
 */
public class OrderItem implements Serializable {
    private final SFunction<?, ?> column;
    private final String direction; // ASC 或 DESC

    public OrderItem(SFunction<?, ?> column, String direction) {
        this.column = column;
        this.direction = direction;
    }

    // Getters
    public SFunction<?, ?> getColumn() {
        return column;
    }

    public String getDirection() {
        return direction;
    }

    /**
     * 生成排序SQL片段
     */
    public String toSQL() {
        String columnName = LambdaUtils.column(column);
        return columnName + " " + direction;
    }
}
